/**
 * Types
 */
import type { Response } from '@/vite-env';
import axios from './index';

/**
 * APIs
 */
// 登录
export function login(data: LoginData) {
    return axios<Response>('/user/pc/login', {
        data,
        method: 'post',
    });
}

// 注册
export function register(data: RegisterData) {
    return axios<Response>('/user/pc/register', {
        data,
        method: 'post',
    });
}

// 验证码
export function code(data: CodeData) {
    return axios<Response>('/user/sms/code', {
        data,
        method: 'post',
    });
}


// 登录
export type LoginData = {
    /**
     * 登录方式
     *
     * @example 0 用户名密码登录 1 用户名验证码登录
     */
    loginType: 0 | 1;
    phone: string;
    code?: string;
    password?: string;
};

// 注册
export type RegisterData = {
    code: string;
    password: string;
    phone: string;
};

// 验证码
export type CodeData = {
    /**
     * 验证码类型
     *
     * @example 0 登录 1 忘记密码 2 修改密码
     */
    codeType: 0 | 1 | 2;
    phone: string;
};
